package com.pine.app.module.security.oauth.support.code;


import com.pine.app.module.security.core.common.AuthConstant;
import com.pine.app.module.security.oauth.support.AbstractHttpTokenRequest;

import javax.servlet.http.HttpServletRequest;


/**
 * @author xiaoyuan
 * @create 2019/9/30 14:28
 **/
public class HttpAuthorizationCodeRequest extends AbstractHttpTokenRequest implements AuthorizationCodeRequest {

    private String code;
    private String redirectUri;
    private String responseType;


    public HttpAuthorizationCodeRequest(HttpServletRequest request) {
        super(request);
        this.code = this.parameters.get(AuthConstant.code);
        this.redirectUri = this.parameters.get(AuthConstant.redirect_uri);
        this.responseType = this.parameters.get(AuthConstant.response_type);

    }

    @Override
    public String getClientId() {
        return this.getClientCredentials().getPrincipal();
    }

    @Override
    public String getClientSecret() {
        return this.getClientCredentials().getCredentials();
    }

    @Override
    public String getRedirectUri() {
        return redirectUri;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getResponseType() {
        return responseType;
    }

}
